﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20170207_DbConnection
{
    abstract class DatabaseConnection
    {
        private string connectionString;
        private TimeSpan timeOut;

        public DatabaseConnection(string connectionString, TimeSpan timeOut)
        {
            ConnectionString = connectionString;
            TimeOut = timeOut;
        }

        public string ConnectionString
        {
            get { return connectionString; }
            private set
            {
                if (String.IsNullOrEmpty(value))
                    throw new ArgumentException("Connection String is null or empty");
                connectionString = value;
            }
        }

        public TimeSpan TimeOut
        {
            get { return timeOut; }
            private set
            {
                if (value > TimeSpan.Zero)
                    timeOut = value;
                else
                    throw new ArgumentException("TimeOut is less than zero");
            }
        }

        abstract public void OpenConnection();

        abstract public void CloseConnection();
    }
}
